import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import { GlobalState } from '@/renderer/global';

const state = new GlobalState();
const adminChildren: RouteRecordRaw[] = [];
for (const menu of state.menu.list) {
  adminChildren.push({
    path: menu.path,
    name: menu.name,
    component: menu.component,
    meta: {
      code: menu.code
    }
  });
}
/**路由列表*/
const routes = [
  {
    path: '/',
    redirect: '/admin'
  },
  {
    path: '/admin',
    name: 'admin',
    component: () => import('@/renderer/layouts/index.vue'),
    redirect: '/admin/home',
    children: adminChildren
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: routes
});

export default router;
